package com.xiangyang.utils;

import java.util.Random;

public class CaptchaGenerator {

    private static final Random RANDOM = new Random();

    /**
     * 生成指定长度的数字验证码
     *
     * @param length 验证码长度
     * @return 生成的验证码
     */
    public String generateNumericCaptcha(int length) {
        StringBuilder captcha = new StringBuilder();
        for (int i = 0; i < length; i++) {
            int randomDigit = RANDOM.nextInt(10); // 生成0-9之间的随机数字
            captcha.append(randomDigit);
        }
        return captcha.toString();
    }


}